/**
 * 
 * 广州锐鹏计算机科技有限公司（www.ruipengkj.com）
 * 
 * 
 * Copyright (c) 2011-2012 RUIPENGKJ.Co.Ltd. All rights reserved.
 * 
 * */
package com.ruipengkj.model;
/**
 * 说明：
 * 商品列表Model
 * @Author：黄盛强
 * @Date：2012-03-30
 */
import java.util.List;
import java.util.Vector;

import javax.swing.table.AbstractTableModel;

import com.ruipengkj.bean.TRight;

public class MemberQueryRightModel extends AbstractTableModel {

	private static final long serialVersionUID = 1L;
	private List<TRight> tRightList=new Vector<TRight>();
	private Vector<String> columns = new Vector<String>();
	
	private boolean[] bools;
	private String[] rightType;
	
	public MemberQueryRightModel(){
		columns.add("选择");
		columns.add("类型");
		columns.add("权限名称");
		//columns.add("roleID");
	}
	//获取列对应的类型
	public Class getColumnClass(int column){
		return Object.class;
	}
	//获得行数
	public int getRowCount(){
		return tRightList.size();
	}
	//获得列数
	public int getColumnCount(){
		return columns.size();
	}
	
	//获得单元格的值
	public Object getValueAt(int row,int column){
//		if (row >= tCommodityList.size())
//			return null;
		TRight tRight = tRightList.get(row);
		return gettCommodityValueByCol(tRight, row, column);
	}
	
	public Object gettCommodityValueByCol(TRight tRight, int row, int column) {
		switch (column) {
			case 0:
				return bools[row];
			case 1:
				return rightType[row];
			case 2:
				return tRight.getName();
//			case 3:
//				return tRight.getRightID();
		}
		return null;
	}
	
	//获取列名
	public String getColumnName(int column){
		return (String)columns.get(column);
	}
	
	//设置单元格是否可编辑
	public boolean isCellEditable(int rowIndex,int columnIndex){
//		if (columnIndex == 0 || columnIndex == 4) 
		if (columnIndex == 0 ) 
			return true;
		return false;
	}
	
	public void removeData(int row){
		tRightList.remove(row);
	}
	//设置单元格的值
	public void setValueAt(Object aValue,int rowIndex,int columnIndex){
		TRight tCommodity = tRightList.get(rowIndex);
		switch (columnIndex) {
			case 0:
				bools[rowIndex] = (Boolean)aValue;
				return;
		}
		super.setValueAt(aValue, rowIndex, columnIndex);
	}

	public List<TRight> getTCommodityList() {
		return tRightList;
	}

	public boolean[] getBools() {
		return bools;
	}
	
	public String[] getRightType(){
		return rightType;
	}
	
	public void setRowData(List<TRight> tRightList) {
		this.tRightList = tRightList;
		for (int i = tRightList.size() - 1; i >= 0; --i) {
			//tCommodityList.get(i).setNum(1);
		}
		bools = new boolean[tRightList.size()];
		rightType = new String[tRightList.size()];
	}
	
	public List<TRight> getTRightList() {
		return tRightList;
	}
}
